<?php
$code = '<?php echo "la phrase $x[5] pou x"; echo \'autre phrase\', "\n"; ?>';
$tokens = token_get_all($code);
foreach( $tokens as $token ) {
    if( is_array( $token ) ) echo token_name( $token[0]), ' : ', $token[1], "\n";
    else echo '- : ', $token, "\n";
}
